#include<iostream>
#include<cstdio>
using namespace std;
int n;
int l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	int a=l%n,b=r%n;
	if(b>a){
		cout<<b<<endl;
	}else{
		cout<<n-1<<endl;
	}
	return 0;
}
